package com.czxy.service;

import com.czxy.dao.ProductMapper;
import com.czxy.domain.Product;
import com.czxy.utils.MyBatisUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;

public class ProductService {


    public PageInfo<Product>  findByP (int pageNum, int pageSize){

        ProductMapper mapper = MyBatisUtils.getMapper(ProductMapper.class);

        //分页
        PageHelper.startPage(pageNum,pageSize);


        List<Product> list = mapper.findAll();

        PageInfo<Product> pageInfo = new PageInfo<>(list);

        MyBatisUtils.close();

        return pageInfo;
    }




    public  List<Product> findByPage(int pageNum, int pageSize){

        ProductMapper mapper = MyBatisUtils.getMapper(ProductMapper.class);

        //分页
        PageHelper.startPage(pageNum,pageSize);


        List<Product> list = mapper.findAll();

        MyBatisUtils.close();

        return list;
    }










    public List<Product> findAll(){

        ProductMapper mapper = MyBatisUtils.getMapper(ProductMapper.class);

        List<Product> list = mapper.findAll();
        MyBatisUtils.close();


        return list;
    }




}
